package com.mz.mattress.admin.api.admin;

import com.mz.mattress.admin.service.SysParamService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.SysParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@Slf4j
@RestController
@RequestMapping(Constants.ADMIN_PATH + "param")
public class ParamController {

    @Autowired
    private SysParamService sysParamService;

    @GetMapping("/list")
    public Result<List<SysParam>> list() {
        return sysParamService.list();
    }

    @GetMapping("/{id}")
    public Result<SysParam> detail(@PathVariable Integer id) {
        return sysParamService.getById(id);
    }

    @PostMapping
    public Result add(@RequestBody SysParam sysParam) {
        return sysParamService.add(sysParam);
    }

    @PutMapping
    public Result update(@RequestBody SysParam sysParam) {
        return sysParamService.updateById(sysParam);
    }

    @DeleteMapping
    public Result delete(@RequestBody Set<Integer> ids) {
        return sysParamService.deleteByIds(ids);
    }

}
